<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h2>props</h2>
      <!-- props的语法：推荐传递的时候使用连字符，props接受的时候使用小驼峰 -->
      <!-- 在自定义属性的前面加v-bind,引号里面就是表达式 -->
      <!-- <child msg="hello" :page-count="count" :age="20" :post="post"></child> -->
      <child msg="hello" :page-count="count" :age="20" v-bind="post"></child>
    </div>

    <script src="./lib/vue3.js"></script>
    <script>
      const { createApp } = Vue;

      const Child = {
        // 数组的语法
        // props: ["msg", "count"],

        // 对象的语法
        props: {
          msg: String,
          pageCount: Number,
          age: Number,
          // post: Object,
          id: Number,
          title: String,
        },
        template: `
          <div>child子组件 - {{ msg }} - {{ pageCount }}</div>
          <p>age: {{ age }}</p>
          <p>{{ id }} - {{ title }}</p>
        `,
      };

      createApp({
        data() {
          return {
            count: 10,
            post: {
              id: 1,
              title: "My Journey with Vue",
            },
          };
        },
        components: {
          Child,
        },
      }).mount("#app");
    </script>
  </body>
</html>
